<template>
  <el-dialog title="查看" :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="700px">
    <el-form ref="form" :model="form" label-width="100px" class="viewForm">
      <el-form-item label="主题：" prop="theme">
        {{form.theme_name}}
      </el-form-item>
      <el-form-item label="用户ID：" prop="u_id">
        {{form.u_id}}
      </el-form-item>
      <el-form-item label="用户姓名：" prop="name">
        {{form.name}}
      </el-form-item>
      <el-form-item label="手机号码：" prop="phone">
        {{form.phone}}
      </el-form-item>
      <el-form-item label="公司名称：" prop="company_name">
        {{form.company_name}}
      </el-form-item>
      <el-form-item label="行业：" prop="industry_name">
        {{form.industry_name}}
      </el-form-item>
      <el-form-item label="提交时间：" prop="create_time">
        {{form.create_time}}
      </el-form-item>
      <el-form-item label="跟进结果：" prop="msg">
        {{form.msg}}
      </el-form-item>
      <ul class="logsList" v-if="logsInfo && logsInfo.length>0">
        <li v-for="(item,index) in logsInfo" :key="index">
          <div class="time-big">
            <div class="mobile">
              <div class="code">创建人</div>
              <span>{{item.admin.user_login}}</span>
            </div>
            <div class="createTime">
              <div class="code">创建时间</div>
              {{item.create_time}}
            </div>
          </div>
          <div class="content">
            <div class="code">跟进内容</div>
            <span>{{item.msg}}</span>
          </div>
        </li>
      </ul>
      <!--<div v-else class="nodata"><img src="../../assets/images/nodata.jpg"/></div>-->

    </el-form>
    <div slot="footer" class="footer-btn">
      <el-button type="primary" @click="handleCloseDialog">关闭</el-button>
    </div>

  </el-dialog>

</template>

<script>
  import { validPhone } from '@/utils/validate'
  import { reqServeById, reqAdviceThemeList, reqAdminMsgList } from '@/api/customerServiceMgt/index'

  export default {
    name: 'viewServe',
    data() {
      return {
        form: {
          theme_name: null,
          u_id: '',//用户id
          name: '',//名称
          phone: '',//手机号码
          company_name: '',//公司名称
          industry_name: '',//行业
          create_time: '',//联系时间
          msg: ''//跟进结果
        },
        themeList: [],
        logsInfo: [],//跟进记录
      }
    },
    created() {
      this.getServeById();//获取详情
      this.getAdviceThemeList();//获取主题
      this.getAdminMsgList();//获取跟进记录
    },
    mounted() {
    },
    watch: {},
    methods: {
      getAdminMsgList() {
        reqAdminMsgList(this.$attrs.id).then(res => {
              console.log('跟进记录',res.data);
              this.logsInfo=res.data;
        });
      },
      getServeById() {
        reqServeById(this.$attrs.id).then(res => {
          this.form.theme_name = res.data.theme_name//获取主题id;
          const { u_id, name, phone, company_name, industry_name, create_time, msg } = res.data
          this.form.u_id = u_id
          this.form.name = name
          this.form.phone = phone
          this.form.company_name = company_name
          this.form.industry_name = industry_name
          this.form.create_time = create_time
          this.form.msg = msg
          console.log('根据id获取详情', this.form)
        })
      },
      getAdviceThemeList() {
        reqAdviceThemeList().then(res => {
          let data = res.data
          for (let key in data) {
            let obj = {
              value: key,
              label: data[key]
            }
            this.themeList.push(obj)

          }
        })
        console.log('主题', this.themeList)
      },
      handleCloseDialog() {
        this.$emit('update:visableIf', false)
        this.$emit('handleCloseFilter') //关闭弹窗;
      }
    }
  }
</script>

<style scoped lang="scss">
  .logsList {
    padding-left: 0px;

    li {
      background: #F7F9FF;
      border: 1px solid #ABC0DE;
      display: flex;
      justify-content: space-between;
      flex-direction: column;
      box-sizing: border-box;
      padding: 16px 0px;
      color: #000;
      margin-bottom: 10px;

      .time-big {
        padding: 0px 20px;
        display: flex;
        justify-content: space-between;

        .code {
          margin-bottom: 6px;
        }

        span {
          font-weight: bold;
        }
      }

      .content {
        border-top: 1px solid #ABC0DE;
        padding: 10px 20px;
        margin-top: 10px;

        .code {
          margin-bottom: 6px;
        }
      }

    }
  }

  .nodata {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;

    img {
      width: 200px;
      height: auto;
    }
  }
</style>
